package com.gitee.minimalismstyle.fresh.common.dubbo.annotation

import org.apache.dubbo.common.constants.RegistryConstants
import org.apache.dubbo.config.annotation.DubboReference
import org.apache.dubbo.config.annotation.Method
import java.lang.annotation.*
import java.lang.annotation.Retention
import java.lang.annotation.Target
import kotlin.reflect.KClass

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE)
@Inherited
@DubboReference
annotation class FreshDubboReference(
    /**
     * Interface class, default value is void.class
     */
    val interfaceClass: KClass<*> = Unit::class,

    /**
     * Interface class name, default value is empty string
     */
    val interfaceName: String = "",

    /**
     * Service version, default value is empty string
     */
    val version: String = "",

    /**
     * Service group, default value is empty string
     */
    val group: String = "",

    /**
     * Service target URL for direct invocation, if this is specified, then registry center takes no effect.
     */
    val url: String = "",

    /**
     * Client transport type, default value is "netty"
     */
    val client: String = "",

    /**
     * Whether to enable generic invocation, default value is false
     */
    val generic: Boolean = false,

    /**
     * When enable, prefer to call local service in the same JVM if it's present, default value is true
     */
    val injvm: Boolean = true,

    /**
     * Check if service provider is available during boot up, default value is true
     */
    val check: Boolean = true,

    /**
     * Whether eager initialize the reference bean when all properties are set, default value is false
     */
    val init: Boolean = false,

    /**
     * Whether to make connection when the client is created, the default value is false
     */
    val lazy: Boolean = false,

    /**
     * Export an stub service for event dispatch, default value is false.
     *
     *
     * see org.apache.dubbo.rpc.Constants#STUB_EVENT_METHODS_KEY
     */
    val stubevent: Boolean = false,

    /**
     * Whether to reconnect if connection is lost, if not specify, reconnect is enabled by default, and the interval
     * for retry connecting is 2000 ms
     *
     *
     * see org.apache.dubbo.remoting.Constants#DEFAULT_RECONNECT_PERIOD
     */
    val reconnect: String = "",

    /**
     * Whether to stick to the same node in the cluster, the default value is false
     *
     *
     * see Constants#DEFAULT_CLUSTER_STICKY
     */
    val sticky: Boolean = false,

    /**
     * How the proxy is generated, legal values include: jdk, javassist
     */
    val proxy: String = "",

    /**
     * Service stub name, use interface name + Local if not set
     */
    val stub: String = "",

    /**
     * Cluster strategy, legal values include: failover, failfast, failsafe, failback, forking
     */
    val cluster: String = "",

    /**
     * Maximum connections service provider can accept, default value is 0 - connection is shared
     */
    val connections: Int = 0,

    /**
     * The callback instance limit peer connection
     *
     *
     * see org.apache.dubbo.rpc.Constants#DEFAULT_CALLBACK_INSTANCES
     */
    val callbacks: Int = 0,

    /**
     * Callback method name when connected, default value is empty string
     */
    val onconnect: String = "",

    /**
     * Callback method name when disconnected, default value is empty string
     */
    val ondisconnect: String = "",

    /**
     * Service owner, default value is empty string
     */
    val owner: String = "",

    /**
     * Service layer, default value is empty string
     */
    val layer: String = "",

    /**
     * Service invocation retry times
     *
     *
     * see Constants#DEFAULT_RETRIES
     */
    val retries: Int = 2,

    /**
     * Load balance strategy, legal values include: random, roundrobin, leastactive
     *
     *
     * see Constants#DEFAULT_LOADBALANCE
     */
    val loadbalance: String = "",

    /**
     * Whether to enable async invocation, default value is false
     */
    val async: Boolean = false,

    /**
     * Maximum active requests allowed, default value is 0
     */
    val actives: Int = 0,

    /**
     * Whether the async request has already been sent, the default value is false
     */
    val sent: Boolean = false,

    /**
     * Service mock name, use interface name + Mock if not set
     */
    val mock: String = "return {'success':false,'message':'服务器不可用'}",

    /**
     * Whether to use JSR303 validation, legal values are: true, false
     */
    val validation: String = "",

    /**
     * Timeout value for service invocation, default value is 0
     */
    val timeout: Int = 0,

    /**
     * Specify cache implementation for service invocation, legal values include: lru, threadlocal, jcache
     */
    val cache: String = "",

    /**
     * Filters for service invocation
     *
     *
     * see Filter
     */
    val filter: Array<String> = arrayOf(),

    /**
     * Listeners for service exporting and unexporting
     *
     *
     * see ExporterListener
     */
    val listener: Array<String> = arrayOf(),

    /**
     * Customized parameter key-value pair, for example: {key1, value1, key2, value2}
     */
    val parameters: Array<String> = arrayOf(),

    /**
     * Application associated name
     */
    val application: String = "",

    /**
     * Module associated name
     */
    val module: String = "",

    /**
     * Consumer associated name
     */
    val consumer: String = "",

    /**
     * Monitor associated name
     */
    val monitor: String = "",

    /**
     * Registry associated name
     */
    val registry: Array<String> = arrayOf(),

    /**
     * The communication protocol of Dubbo Service
     *
     * @return the default value is ""
     * @since 2.6.6
     */
    val protocol: String = "",

    /**
     * Service tag name
     */
    val tag: String = "",

    /**
     * Service merger
     */
    val merger: String = "",

    /**
     * methods support
     */
    val methods: Array<Method> = arrayOf(),

    /**
     * The id
     *
     * @return default value is empty
     * @since 2.7.3
     */
    val id: String = "",

    /**
     * @return The service names that the Dubbo interface subscribed
     * @see RegistryConstants.SUBSCRIBED_SERVICE_NAMES_KEY
     *
     * @since 2.7.8
     */
    val services: Array<String> = arrayOf()
)
